#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include"map.h"
#include <QWidget>
#include<QTimer>
#include"plane.h"
#include"bullet.h"
#include"enemyplane.h"
#include"config.h"
#include"bomb.h"
#include"skill.h"
#include"score.h"
#include <QMainWindow>
#include <QSoundEffect>
#include<QPixmap>
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    //初始化
    void initscene();

    //启动游戏
    void playgame();

    QPixmap beginbackground;
    QPixmap selectbackground;
    bool isbegin;
    bool isselect;
    //更新坐标
    void updateposition();

    //绘制到屏幕中
    void paintEvent(QPaintEvent*);

    //地图对象
    Map m_map;

    //鼠标移动事件
    void mouseMoveEvent(QMouseEvent*event);

    //键盘操作
    void keyPressEvent(QKeyEvent *event);
    //定时器
    QTimer m_Timer;

    //飞机对象
    plane m_plane;


    //敌机
    enemyplane m_enemy[enemy_num];
    enemyplane boss;
    //敌机出场
    void enemyToscene();
    void bossstatu();

    //敌机出场间隔记录
    int m_recorder;

    //碰撞检测
    void collisionDetection();

    //爆炸数组
    bomb m_boom[bomb_num];


    //技能
    void sumskill();
    skill m_skill1;
    //1
    bool s1=false;
    void skill1statu();
    void skill1begin();
    //2
    skill m_skill2[skill2_num];
    bool s2=false;
    void skill2toscene();
    void skill2statu();
    void skill2begin();
    int recorder=0;
    //3
    void skill3statu();
    void skill3begin();

    //4
    void skill4statu();
    void skill4begin();

//抖动
    void maptremble();


    //等级
    void levelup();
    void levelstatu();
    bool level=false;

    //升级
    int grade=0;
    void gradetoscene();

    //发射子弹类型
    void shoot();

    //分数文字
    score m_score;
    void scoreupdate();
    void scoretoscene();
    void judgmenttoscene();
    //角色血量
    int player_hp;
    void hurt();
    void hptoscene();

    bool begin=false;
//
    void skillstatutoscene();

 //
    int skillrecorder1=0;
    int skillrecorder2=0;
    int skillrecorder3=0;
    int skillrecorder4=0;
//子弹坐标计算
    void bulletposition();


 //游戏结束
    void ending();

  //重新开始
    void regame();

   //音效
    QSoundEffect * startSound = new QSoundEffect(this);
    QSoundEffect * elseSound = new QSoundEffect(this);
    QSoundEffect * pointSound= new QSoundEffect(this);
//最高得分
    int record=0;
    void recordtoscene();
    void congratulationtoscene();
    bool newscore=false;//成绩是否变高
    //难度
    void difficult();
    void simple();
    void updatenemyspeed();
    int hpnow=1;
    bool difficultup=false;
    void difficultstatutoscene();
private slots:
    void on_pushButton_clicked();

    void on_pause_clicked();

    void on_continue_2_clicked();

    void on_pushButton_2_clicked();

    void on_difficult_clicked();

    void on_simple_clicked();

    void on_back_clicked();

private:
    Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
